<?php

/*
=====================================================
 FluxBB - Delux Board Converstations (DBC)
-----------------------------------------------------
 http://dbc-forum.com/
 http://fluxbb.org/
-----------------------------------------------------
 Copyright (c) 2010,2011 FluxBB - Delux Board Conversations (DBC)
-----------------------------------------------------
 Предсловие: Данный скрипт (DBC) не является работой с нуля, то 
 есть ядром скрипта всё также остаётся FuxBB,но теперь в оболочке
 DBC.
=====================================================
*/

// Make sure no one attempts to run this script "directly"
if (!defined('DBC'))
	exit;

// Load the language file
require DBC_ROOT.'language/'.$admin_language.'/admin_plugin_security.php';

// Tell admin_loader.php that this is indeed a plugin and that it is loaded
define('DBC_PLUGIN_LOADED', 1);

// If the "Show text" button was clicked
if (isset($_POST['show_text']))
{
  $b_kolvo = isset($_POST['blocking_kolvo']) ? intval($_POST['blocking_kolvo']) : 0;
  $b_time = isset($_POST['blocking_time']) ? intval($_POST['blocking_time']) : 0;
  $b_kolvo = ($b_kolvo < 0) ? 0 : $b_kolvo;
  $b_time = ($b_time < 0) ? 0 : $b_time;
  $b_reglog = isset($_POST['blocking_reglog']) ? intval($_POST['blocking_reglog']) : 0;
  $b_guest = isset($_POST['blocking_guest']) ? intval($_POST['blocking_guest']) : 0;
  $b_user = isset($_POST['blocking_user']) ? intval($_POST['blocking_user']) : 0;
  $b_coding_forms = isset($_POST['coding_forms']) ? intval($_POST['coding_forms']) : 0;
  $b_check_ip = isset($_POST['check_ip']) ? intval($_POST['check_ip']) : 0;
  $b_redirect = isset($_POST['board_redirect']) ? DBC_trim($_POST['board_redirect']) : '';
  $b_redirectg = isset($_POST['board_redirectg']) ? intval($_POST['board_redirectg']) : 0;

	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$b_kolvo.'\' WHERE conf_name=\'o_blocking_kolvo\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$b_time.'\' WHERE conf_name=\'o_blocking_time\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$b_reglog.'\' WHERE conf_name=\'o_blocking_reglog\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$b_guest.'\' WHERE conf_name=\'o_blocking_guest\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$b_user.'\' WHERE conf_name=\'o_blocking_user\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$b_coding_forms.'\' WHERE conf_name=\'o_coding_forms\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$b_check_ip.'\' WHERE conf_name=\'o_check_ip\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$db->escape($b_redirect).'\' WHERE conf_name=\'o_board_redirect\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());
	$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$b_redirectg.'\' WHERE conf_name=\'o_board_redirectg\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error());

	if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
		require DBC_ROOT.'engine/cache.php';

	generate_config_cache();

	redirect(DBC_htmlspecialchars('admin_loader.php?plugin=AP_Security.php'), $lang_admin_plugin_security['Plugin redirect']);

}
else
{
	// Display the admin navigation menu
	generate_admin_menu($plugin);

	$cur_index = 1;
	
?>
	<div class="plugin blockform">

<table width="100%" height="38" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="28" class="bg_forum_title_left"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="left" class="bg_forum_title_center"><span class="cat_title"><?php echo $lang_admin_plugin_security['Plugin title'] ?></span></td>
<td align="center" width="28" class="bg_forum_title_right"><img src="engine/skins/images/spacer.gif" border="0"></td>
</tr></table>

<table class="forum_adv_table"  width="100%" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" class="forum_adv_tleft" width="2"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="left" width="100%"><div class="forum_adv_c">

			<form id="example" method="post" action="<?php echo DBC_htmlspecialchars($_SERVER['REQUEST_URI']) ?>&amp;foo=<?php echo time() ?>"><br/>
				<div class="inform">
					<fieldset>
						<div class="login_info"><?php echo $lang_admin_plugin_security['Form title'] ?></div>
						<div class="infldset">
						<p><?php echo $lang_admin_plugin_security['Explanation 1'] ?></p>
						<p><?php echo $lang_admin_plugin_security['Explanation 2'] ?></p>
							<table class="aligntop" cellspacing="10">
								<tr>
									<td>
										<span><?php echo $lang_admin_plugin_security['Allow'] ?>&nbsp;<input type="text" class="input_text" name="blocking_kolvo" size="5" maxlength="5" tabindex="<?php echo ($cur_index++) ?>" value="<?php echo DBC_htmlspecialchars($DBC_config['o_blocking_kolvo']) ?>"/>&nbsp;<?php echo $lang_admin_plugin_security['Errors'] ?>&nbsp;
										<input type="text" class="input_text" name="blocking_time" size="8" maxlength="8" tabindex="<?php echo ($cur_index++) ?>" value="<?php echo DBC_htmlspecialchars($DBC_config['o_blocking_time']) ?>"/>&nbsp;<?php echo $lang_admin_plugin_security['Minute'] ?></span>
									</td>
								</tr>
								<tr>
									<td>
										<span><input type="checkbox" name="blocking_reglog" value="1" tabindex="<?php echo ($cur_index++) ?>"<?php echo ($DBC_config['o_blocking_reglog'] == '1') ? ' checked="checked"' : '' ?> />&#160;&#160;<?php echo $lang_admin_plugin_security['Flag Reglog'] ?></span>
									</td>
								</tr>
								<tr>
									<td>
										<span><input type="checkbox" name="blocking_guest" value="1" tabindex="<?php echo ($cur_index++) ?>"<?php echo ($DBC_config['o_blocking_guest'] == '1') ? ' checked="checked"' : '' ?> />&#160;&#160;<?php echo $lang_admin_plugin_security['Flag Guest'] ?></span>
									</td>
								</tr>
								<tr>
									<td>
										<span><input type="checkbox" name="blocking_user" value="1" tabindex="<?php echo ($cur_index++) ?>"<?php echo ($DBC_config['o_blocking_user'] == '1') ? ' checked="checked"' : '' ?> />&#160;&#160;<?php echo $lang_admin_plugin_security['Flag User'] ?></span>
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
				</div>
				
				<div class="inform">
					<fieldset>
						<div class="login_info"><?php echo $lang_admin_plugin_security['Form title2'] ?></div>
						<div class="infldset">
							<table class="aligntop" cellspacing="10">
								<tr>
									<td>
										<span><input type="checkbox" name="coding_forms" value="1" tabindex="<?php echo ($cur_index++) ?>"<?php echo ($DBC_config['o_coding_forms'] == '1') ? ' checked="checked"' : '' ?> />&#160;&#160;<?php echo $lang_admin_plugin_security['Coding forms'] ?></span>
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
				</div>

				<div class="inform">
					<fieldset>
						<div class="login_info"><?php echo $lang_admin_plugin_security['Form title3'] ?></div>
						<div class="infldset">
							<table class="aligntop" cellspacing="10">
								<tr>
									<td>
										<span><input type="checkbox" name="check_ip" value="1" tabindex="<?php echo ($cur_index++) ?>"<?php echo ($DBC_config['o_check_ip'] == '1') ? ' checked="checked"' : '' ?> />&#160;&#160;<?php echo $lang_admin_plugin_security['Check IP'] ?></span>
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
				</div>
				<div class="inform">
					<fieldset>
						<legend><?php echo $lang_admin_plugin_security['Form title4'] ?></legend>
						<div class="infldset">
							<table class="aligntop" cellspacing="10">
								<tr>
									<td>
										<span><?php echo $lang_admin_plugin_security['Board red help'] ?></span>
										<input type="text" class="input_text" name="board_redirect" size="50" maxlength="255" value="<?php echo DBC_htmlspecialchars($DBC_config['o_board_redirect']) ?>"  tabindex="<?php echo ($cur_index++) ?>"/>
									</td>
								</tr>
								<tr>
									<td>
										<label><input type="checkbox" name="board_redirectg" value="1" tabindex="<?php echo ($cur_index++) ?>"<?php echo ($DBC_config['o_board_redirectg'] == '1') ? ' checked="checked"' : '' ?> />&#160;&#160;<?php echo $lang_admin_plugin_security['Board red only guest'] ?></label>
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
				</div><br/>
				<p class="submitend"><input type="submit" class="fbutton" name="show_text" value="<?php echo $lang_admin_plugin_security['Show text button'] ?>" tabindex="<?php echo ($cur_index++) ?>" /></p>
			</form>
<br/>
</div></td>
<td align="left" class="forum_adv_tright" width="2"><img src="engine/skins/images/spacer.gif" border="0"></td>
</td></tr></table>
<table width="100%" height="23" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="30" class="bg_forum_bott_left"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="left" class="bg_forum_bott_center"><img src="engine/skins/images/spacer.gif" border="0"></td>
<td align="center" width="30" class="bg_forum_bott_right"><img src="engine/skins/images/spacer.gif" border="0"></td>
</tr></thead></table>
	</div>
<?php
}